<%-- 
    Document   : index
    Created on : Apr 20, 2012, 1:16:23 PM
    Author     : asus
--%>

<%@page contentType="text/html" pageEncoding="UTF-8"%>
<!DOCTYPE html>
<?php
	session_start();
	include "connect.php";
	include "paging_class_menu.php";
?>	
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>ROUND</title>
<meta http-equiv="content-type" content="application/xhtml+xml; charset=UTF-8" />
	<link rel="stylesheet" type="text/css" href="firststyle.css" />
	<script type="text/javascript" src="validator.js"></script>
	<script type="text/javascript" src="calendar.js"></script>
	<script type="text/javascript" src="index_js.js"></script>
	<script type="text/javascript" src="login.js"></script>
	<script type="text/javascript" src="logout.js"></script>
</head>

<body>
<!-- HEADER -->
		<div class="Logo"><a href="home.php"><img src="res/Roundlogo.png" alt="" /></a></div>
		
		
		<ul class="navigation">
			<li><a href="home.php">Home</a></li>		
			<li><a href="Register.php">Register</a></li>
			<li><a href="src/upload.php">Upload</a></li>
			<li><a href="DaftarKonten.php?page=1">Contents</a></li>
			<?php
			if (isset ($_SESSION["user"])){
				$username = $_SESSION["user"];
				$avatar = mysql_query("select avatar from account where username = '$username'");
				$ravatar = mysql_fetch_array($avatar);
				echo "<li>  Welcome,".$_SESSION["user"]." <img class= avatar src= ".$ravatar["avatar"]." /> </li>";
				echo "<div class=Log>";
				echo "<button id='Log Out' onclick='logout()' type='button'> Log Out </button>";
				echo "</div>";
			} else
			{
				echo "<li>Welcome,Guest</li>";
				echo "<div class=Log>";
				echo "<tr>";
				echo "<td>Username</td><td> : <input type=text name=username id=username></td>";
				echo "<td>Password</td><td> : <input type=password name=password id=password></td>";
				echo "</tr>";
				echo "<button id=Log In onclick=getloginrequest() type=button> Log In </button>";
				echo "</div>";
			}
			?>
		</ul>
		
		<fieldset class="search_bar">
			<legend>Search</legend>
			<div>
				<form name="search_form" action="searchresult.php" method="POST">
					<table>
						<tr>
						
						<td> <input type="radio" name="select" value="search1" /> All Section <br/></td>
						<td> <input type="radio" name="select" value="search2"  /> Username only <br/></td>
						<td> <input type="radio" name="select" value="search3"  /> Content only <br/></td>
						<td> </td>
						<td><input type="text" name="search_box" id="search_box"></td> 
						<td colspan="2"><input type="submit" value="Search"></td>
						</tr>
					</table>
				</form>
			</div>
		</fieldset>
		
		<form class="toplink_form" action="#">
                <div class="topcategory">
					Top Liked
				</div>
		
					<?php
								//$p      = new Paging;
								//$limit  = 2;
								//$position = $p->cariPosisi($limit);
		
								$query=mysql_query("SELECT * FROM post ORDER BY likecount DESC");
								$found=mysql_num_rows($query);
								$querynama = mysql_query("SELECT * FROM account, post where post.idaccount = account.idaccount  ORDER BY likecount DESC");
								
								if ($found > 0)
								{
									for ($i = 0; $i < 3; $i++)
									{
										$r = mysql_fetch_array($query);
										$name = mysql_fetch_array($querynama);
										//echo "<a href=http://www.vgreleases.com/pc/releasedate-344106.aspx>".$r["username"]."</a><br/>";
										echo "<div class =commentbox>";
										echo "<div class=commentinfo>";
											echo $name["username"];
										echo "</div>";
										echo "<div class=commentcontent>";
											echo "<div class =avatarbox>";
												echo "<img class= avatar src=../res/apatar.jpg alt=avatar/>";
											echo "</div>";
											if ($r["type"] == 1){
												echo "  ";
												echo $r["link"];
												echo "<br/>";
											} else
											if ($r["type"] == 2){
												echo "  ";
												echo $r["video"];
												echo "<br/>";
											} else
											if ($r["type"] == 3){
												echo "  ";
												echo $r["image"];
												echo "<br/>";
											}
											echo "it's the next assasin creed game!";
										echo "</div>";
										echo "<div class=Like>";
											echo "<div style=width:200px;>";
												echo "<span id=likes4></span>";
												echo "<button id=like_b4 onclick='like(4)' type=submit><img src=../res/like.png  alt=/></button>";
												echo "<button id=dislike_b4 onclick='dislike(4)' type=submit><img src=../res/dislike.png  alt=/></button>";
											echo "</div>";

											echo "<div><img class= icon src=../res/comment.png alt=/></div>";
										echo "</div>";
										echo "</div>";
									}
								}
								else
								{
								echo "No match found!";
								}
					?>
        </form>
		
		<h1>  </h1>
		
		<form class="toplink_form" action="#">
                <div class="topcategory">
					Top Commented
				</div>
		
					<?php
								//$p      = new Paging;
								//$limit  = 2;
								//$position = $p->cariPosisi($limit);
		
								$query = mysql_query("SELECT * FROM post ORDER BY commentcount DESC");
								$found = mysql_num_rows($query);
								$querynama = mysql_query("SELECT username FROM account, post where post.idaccount = account.idaccount  ORDER BY commentcount DESC");
		
								if ($found > 0)
								{
									for ($i = 0; $i < 3; $i++)
									{
										$r = mysql_fetch_array($query);
										$name = mysql_fetch_array($querynama);
										//echo "<a href=http://www.vgreleases.com/pc/releasedate-344106.aspx>".$r["username"]."</a><br/>";
										echo "<div class =commentbox>";
										echo "<div class=commentinfo>";
											echo $name["username"];
										echo "</div>";
										echo "<div class=commentcontent>";
											echo "<div class =avatarbox>";
												echo "<img class= avatar src=../res/apatar.jpg alt=avatar/>";
											echo "</div>";
											if ($r["type"] == 1){
												echo $r["link"];
												echo "<br/>";
											} else
											if ($r["type"] == 2){
												echo $r["video"];
												echo "<br/>";
											} else
											if ($r["type"] == 3){
												echo $r["image"];
												echo "<br/>";
											}
											echo "<it's the next assasin creed game!>";
										echo "</div>";
										echo "<div class=Like>";
											echo "<div style=width:200px;>";
												echo "<span id=likes4></span>";
												echo "<button id=like_b4 onclick='like(4)' type=submit><img src=../res/like.png  alt=/></button>";
												echo "<button id=dislike_b4 onclick='dislike(4)' type=submit><img src=../res/dislike.png  alt=/></button>";
											echo "</div>";

											echo "<div><img class= icon src=../res/comment.png alt=/></div>";
										echo "</div>";
										echo "</div>";
									}
								}
								else
								{
								echo "No match found!";
								}
					?>
        </form>
		
		<h1>  </h1>
		
		<script type="text/javascript">initialize(10);</script>
		
</body>

</html> 

